package com.juc;


import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

@Slf4j(topic = "c.Test2")
public class Test2 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Callable<Integer> call = new Callable<>(){
            @Override
            public Integer call() throws Exception {
                log.debug("running");
                Thread.sleep(1000);
                return null;
            }
        };

        FutureTask<Integer> futureTask = new FutureTask<>(call);

        Thread thread = new Thread(futureTask,"future");
        thread.start();

        Integer num = futureTask.get();
        log.debug("{}",num);
    }


}
